<?php
// application/common/model/BusinessSystem.php

namespace app\api\model;

use think\Model;

class BusinessSystem extends Model
{
    protected $table = 'system_business';
    protected $autoWriteTimestamp = false;

    // 字段自动完成
    protected $auto = [];
    protected $insert = [];
    protected $update = [];

    // 字段类型转换
    protected $type = [
        'id' => 'integer',
        'sort' => 'integer',
    ];

    // 验证规则
    public $rules = [
        'system_code' => 'require|alphaNum|max:20',
        'system_name' => 'require|chsAlphaNum|max:6',
        'system_tag' => 'require|in:front,back',
        'sort' => 'require|number|max:9999',
        'is_external' => 'require|in:yes,no',
        'display_status' => 'require|in:show,hide',
        'remark' => 'max:150',
    ];

    public $message = [
        'system_code.require' => '系统编码不能为空',
        'system_code.alphaNum' => '系统编码只能包含字母和数字',
        'system_code.max' => '系统编码不能超过20个字符',
        'system_name.require' => '系统名称不能为空',
        'system_name.chsAlphaNum' => '系统名称只能包含中文、字母和数字',
        'system_name.max' => '系统名称不能超过6个字符',
        'system_tag.require' => '系统标签不能为空',
        'system_tag.in' => '系统标签值不正确',
        'sort.require' => '排序不能为空',
        'sort.number' => '排序必须为数字',
        'sort.max' => '排序不能超过4位数',
        'is_external.require' => '是否外链不能为空',
        'is_external.in' => '是否外链值不正确',
        'display_status.require' => '显示状态不能为空',
        'display_status.in' => '显示状态值不正确',
        'remark.max' => '备注不能超过150个字符',
    ];
}